package com.cb.kfc.service.impl;

import com.cb.kfc.dao.IOrdersDao;
import com.cb.kfc.domain.Orders;
import com.cb.kfc.service.IOrdersService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service
@Transactional
public class OrdersServiceImpl  implements IOrdersService {
    @Autowired
    private IOrdersDao ordersDao ;

    @Override
    public List<Orders> findAll(int page, int size) throws Exception {
//        加入pagehelper插件,pageNum是页码值，pageSize是每页显示条数
        PageHelper.startPage(page,size);
        return ordersDao.findAll();
    }

    @Override
    public void save(Orders orders) {

        ordersDao.save( orders);
    }

    @Override
    public Integer deleteProductById(String[] ids) {
        Integer i =ordersDao.delete(ids);
        return i;
    }

    @Override
    public Orders findById(String id) {
        return ordersDao.findById(id);
    }
}
